package zhengqc.set;

import zhengqc.tree.AVLTree;
import zhengqc.tree.TreeTraversalType;

import java.util.Arrays;

public class AVLTreeSet<E extends Comparable<E>> implements Set<E> {

    private AVLTree<E> avl;
    public AVLTreeSet() {
        avl = new AVLTree<>();
    }
    @Override
    public void add(E element) {
        avl.add(element);
    }

    @Override
    public void remove(E element) {
        avl.remove(element);
    }

    @Override
    public boolean contains(E element) {
        return avl.contains(element);
    }

    @Override
    public int getSize() {
        return avl.getSize();
    }

    @Override
    public boolean isEmpty() {
        return avl.isEmpty();
    }

    @Override
    public String toString() {
        return "AVLTreeSet: " + Arrays.toString(this.avl.traversal(TreeTraversalType.INORDER).toArray());
    }
}
